/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package database.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Stefan
 */
@Entity
@Table(name = "user_group")
@NamedQueries({
    @NamedQuery(name = "UserGroup.findAll", query = "SELECT u FROM UserGroup u"),
    @NamedQuery(name = "UserGroup.findByUgid", query = "SELECT u FROM UserGroup u WHERE u.ugid = :ugid"),
    @NamedQuery(name = "UserGroup.findByUgname", query = "SELECT u FROM UserGroup u WHERE u.ugname = :ugname"),
    @NamedQuery(name = "UserGroup.findByUgauthoritylevel", query = "SELECT u FROM UserGroup u WHERE u.ugauthoritylevel = :ugauthoritylevel")})
public class UserGroup implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "UGID")
    private Integer ugid;
    @Basic(optional = false)
    @Column(name = "UGNAME")
    private String ugname;
    @Basic(optional = false)
    @Column(name = "UGAUTHORITYLEVEL")
    private int ugauthoritylevel;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userGroup", fetch = FetchType.LAZY)
    private List<User> userList;

    public UserGroup() {
    	
    }

    public UserGroup(Integer ugid) {
        this.ugid = ugid;
    }

    public UserGroup(Integer ugid, String ugname, int ugauthoritylevel) {
        this.ugid = ugid;
        this.ugname = ugname;
        this.ugauthoritylevel = ugauthoritylevel;
    }

    public Integer getUgid() {
        return ugid;
    }

    public void setUgid(Integer ugid) {
        this.ugid = ugid;
    }

    public String getUgname() {
        return ugname;
    }

    public void setUgname(String ugname) {
        this.ugname = ugname;
    }

    public int getUgauthoritylevel() {
        return ugauthoritylevel;
    }

    public void setUgauthoritylevel(int ugauthoritylevel) {
        this.ugauthoritylevel = ugauthoritylevel;
    }

    public List<User> getUserList() {
        return userList;
    }

    public void setUserList(List<User> userList) {
        this.userList = userList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ugid != null ? ugid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UserGroup)) {
            return false;
        }
        UserGroup other = (UserGroup) object;
        if ((this.ugid == null && other.ugid != null) || (this.ugid != null && !this.ugid.equals(other.ugid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "database.entity.UserGroup[ugid=" + ugid + "]";
    }

}
